from .exception_enum import StatusCodeEnum

class CommonException(Exception):
    """公共异常基类"""
    def __init__(self, enum_cls):
        self.code = enum_cls.code
        self.message = enum_cls.message
        self.enum_cls = enum_cls
        super().__init__(f"{enum_cls.code}: {enum_cls.message}")

class BusinessException(CommonException):
    """业务异常"""
    pass

class APIException(CommonException):
    """API异常"""
    pass

class ValidationException(CommonException):
    """验证异常"""
    def __init__(self, enum_cls, errors=None):
        super().__init__(enum_cls)
        self.errors = errors or {}